package com.visual.avplayer;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.widget.MediaController;
import android.widget.VideoView;

import androidx.appcompat.app.AppCompatActivity;

public class VideoViewActivity extends AppCompatActivity {
    VideoView videoView;
    String host = "http://visualzhang.com:8000/live/sz.flv";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /* 去掉title */
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        /* 设置全屏 */
        setContentView(R.layout.activity_videoview);
        videoView = findViewById(R.id.video_view);
//        videoView.setVideoPath(host);
        videoView.start();
        /* 获取MediaController对象，控制媒体播放 */
        MediaController mc = new MediaController(this);
        videoView.setMediaController(mc);
        /* 设置URI ， 指定数据 */
        videoView.setVideoURI(Uri.parse(host));
        /* 开始播放视频 */
        videoView.start();
        /*请求获取焦点 */
        videoView.requestFocus();
    }

    public static void launch(Context context) {
        context.startActivity(new Intent(context, VideoViewActivity.class));
    }
}